class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int temp = -2000000000, res = nums[0];
        for (auto& it : nums) {
            temp = max(temp + it, it);
            res = max(res, temp);
        }
        return res;
    }
};